|
- import { NextResponse } from 'next/server';
- import { getJob, cancelJob } from '@/lib/transcode';
-
- export const dynamic = 'force-dynamic';
-
- type Ctx = { params: Promise<{ id: string }> };
-
- export async function GET(_req: Request, ctx: Ctx) {
- const { id } = await ctx.params;
- const job = await getJob(id);
- if (!job) return NextResponse.json({ error: 'Job not found' }, { status: 404 });
- return NextResponse.json({
- id: job.id,
- status: job.status,
- progress: job.progress,
- error: job.error,
- outputName: job.outputName,
- });
- }
-
- export async function DELETE(_req: Request, ctx: Ctx) {
- const { id } = await ctx.params;
- const ok = await cancelJob(id);
- if (!ok) return NextResponse.json({ error: 'Cannot cancel (not found or already finished)' }, { status: 404 });
- return NextResponse.json({ success: true });
- }
|